﻿/********
* 
* 
*  Description:
*  Create By Kain at 4/2/2011 3:04:37 PM
*  
*
*  Revision History:
*  Date                  Who                 What
*  
* 
*/

#region

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cherry.Agile.Framework;
#endregion

namespace Cherry.Agile.ServiceModel.Runtime
{
    [Serializable]
    public class SimpleNameFilter : ServiceFilter
    {
        private List<string> names = new List<string>();

        public SimpleNameFilter() { }


        public SimpleNameFilter(string namesToAdd)
        {
            Add(namesToAdd);
        }

        public SimpleNameFilter(IEnumerable<string> namesToAdd)
        {
            names.AddRange(namesToAdd);
        }


        public void Add(string namesToAdd)
        {
            names.Add(namesToAdd.Trim());
        }
        
        public override bool Match(IService service)
        {
            foreach (string name in names)
                if (service.Info.FullName == name)
                    return true;

            return false;
        }
    }
}
